// RadixConverter.h: interface for the CRadixConverter class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_RADIXCONVERTER_H__E2901CAA_F542_457C_99A4_88D4581CBA69__INCLUDED_)
#define AFX_RADIXCONVERTER_H__E2901CAA_F542_457C_99A4_88D4581CBA69__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "HugeCalc.h"

class CHugeInt;
class CHugeIntX;

#define RC_API HUGECALC_API

class RC_API CRadixConverter
{
public:
	explicit CRadixConverter( CONST UINT32 u32Radix, CONST SIGN enumSign = SIGN_POS, CONST LPCVECTOR_UINT32 pVector = NULL );
	explicit CRadixConverter( CONST UINT32 u32Radix, CONST CHugeInt& right );
	explicit CRadixConverter( CONST UINT32 u32Radix, CONST CHugeIntX& right );
	// For bases up to 36, case is ignored; upper-case and lower-case letters have the same value.
	// For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case letter
	//     represent 36..61.
	explicit CRadixConverter( CONST UINT32 u32Radix, CONST LPCTSTR lpszNum );
	explicit CRadixConverter( CONST CRadixConverter& right );
	/*virtual */~CRadixConverter();

	static CONST UINT32 GetCount( VOID );

	// reload operator ->
	CRadixConverter * CONST operator ->( VOID );

	CRadixConverter& Convert2Radix( CONST UINT32 u32NewRadix );

	CRadixConverter& operator =( CONST CRadixConverter& right );
	CRadixConverter& operator =( CONST CHugeInt& right );
	CRadixConverter& operator =( CONST CHugeIntX& right );

	CRadixConverter& operator =( CONST SINT32& s32Num );
	CRadixConverter& operator =( CONST SINT64& s64Num );
	CRadixConverter& operator =( CONST UINT32& u32Num );
	CRadixConverter& operator =( CONST UINT64& u64Num );

	// Return non-zero if the value of (*this) fits in SINT32, UINT32, SINT64 or UINT64, respectively. Otherwise, return zero.
	operator CONST SINT32( VOID ) CONST;
	operator CONST SINT64( VOID ) CONST;
	operator CONST UINT32( VOID ) CONST;
	operator CONST UINT64( VOID ) CONST;

	VOID ResetRadix( CONST UINT32 u32Radix );
	VOID ResetSign( CONST SIGN enumSign );
	VOID ResetVector( CONST CVECTOR_UINT32& vU32Num );
	VOID ClearVector( VOID );

	CONST UINT32 GetRadix( VOID ) CONST;
	CONST SIGN GetSign( VOID ) CONST;
	CONST CVECTOR_UINT32& GetVector( CVECTOR_UINT32& vU32Num ) CONST;
	CONST UINT64 SumOfDigits( VOID ) CONST;

private:
	UINT32 m_u32Radix;
	SIGN m_enumSign;
	CVECTOR_UINT32 * CONST m_pVector;
};

#endif // !defined(AFX_RADIXCONVERTER_H__E2901CAA_F542_457C_99A4_88D4581CBA69__INCLUDED_)